import './action.dart';
import './state.dart';

AppState mainReducer(AppState state, dynamic action) {

  if(action is ColorTopicActions) {
    colorTopic(state, action);
  }

  if(action is ExamSettingActions) {
    examSetting(state, action);
  }

  return state;
}

// 颜色主题
void colorTopic(AppState state , dynamic action) {
  switch (action) {
    case ColorTopicActions.darkTopic:
      state.colorTopicState.ct = 1;
      break;
    default:
      state.colorTopicState.ct = 0;
      break;
  }
}

// 考试设置
void examSetting(AppState state, dynamic action) {
  switch (action) {
    case ExamSettingActions.jumpToNextSubject:
      print('jump to next');
      break;
    case ExamSettingActions.restOnCurSubject:
      print('rest on current');
      break;  
    default:
      break;
  }
}